#include "timer.h"


void timer_init(int timer, int mode) //only mode 3 matters
{
		
	outportb(TIMER_CTRL, mode | (timer << 6));

}

void timer_load(int timer, int value) 
{
			
	int timer_addr; //timer address (0 or 2)
	
	switch(timer) {
	
		case 0:
			timer_addr = TIMER_0; 
			break;
			
		case 1: 
			return;
			
		case 2: 
			timer_addr = TIMER_2; 
			break;
			
		default: 
			return;
	}
	
	outportb(timer_addr, LSB(value));
	
	outportb(timer_addr, MSB(value));
}



extern int milisec;

void mili_sleep(int mili) 
{
	int time = milisec + mili;
	
	while ( milisec < time ) {
		//do nothing
	}
}




void sec_sleep(int secs) 
{
	mili_sleep(secs * 1000);
}


